package cc.fs.study.drawandevent;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ScrollView;

import cc.fs.study.R;

public class DrawActivity extends AppCompatActivity {
    VScrollView scrollView1;
    HorizontalScrollView scrollView2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_draw);

        getWindow().getDecorView().setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                e("window 处理事件");
                return false;
            }
        });

        Handler handler = new Handler();

        setupEvent();
    }

    private void setupEvent() {
        scrollView1 = (VScrollView)findViewById(R.id.scrollView1);
        scrollView2 = (HorizontalScrollView)findViewById(R.id.scrollView2);
    }

    //是否消耗当前事件
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        //系统及时间可以在这里处理,譬如点击非键盘区域隐藏键盘等
//        e("activit 消耗事件");
        return super.dispatchTouchEvent(ev);
    }

    //处理当前事件
    @Override
    public boolean onTouchEvent(MotionEvent event) {
//        e("activit 处理事件");
        return super.onTouchEvent(event);
    }

    public void e(String msg) {
        Log.e(this.getClass().getSimpleName(), msg);
    }
}
